package com.atguigu.bigdata.chapter05.source;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author lzc
 * @Date 2022/9/2 9:12
 */
public class Flink02_Source_List {
    public static void main(String[] args) {
        // 把集合中的数据放入到flink的流中
        
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", 2000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);
    
        /*List<String> list = Arrays.asList("a", "aa", "b", "c", "d");
        DataStreamSource<String> source = env.fromCollection(list);*/
    
        DataStreamSource<String> source = env.fromElements("a", "b", "c", "d");
    
        source.print();
    
    
        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
